<?php
// 本类由系统自动生成，仅供测试用途
class NewsAction extends CommAction{
    public function index(){
		
		import("ORG.Util.Page");

		$cid = $_GET['cid'];	
		$news = M("article");
		$count = $news->count();
		$p  = new Page ($count, 10);
		
		$p->setConfig('header','篇记录');
		$p->setConfig('prev',"<");
		$p->setConfig('next','>');
		$p->setConfig('first','<<');
		$p->setConfig('last','>>');

		
		$news_array = $news->order('ctime desc')->limit($p->firstRow.','.$p->listRows)->findAll();
		
		$page = $p->show (); 	

		//dump($news_array);
		$news_string = "";
		foreach($news_array as $v){
			
			$news_string = $news_string."<li><a href='__APP__/News/news_show/nid/".$v['id']."/nowp/".$p->nowPage."' >".$v['title']."</a><span class='news_time'>".date('Y-m-d H:i:s',$v['ctime'])."</span></li>";
			
			
		}
		$news = "<ul>".$news_string."</ul>";
				
		$this->assign('news_result',$news); // 模板变量赋值   
		$this->assign('cid',$cid);
		$this->assign ("page", $page );
		$this->assign ("current_p",$p->nowPage);
   		$this->display("public:news");
    
     }


	 public function news_show() { 

		$news_id = $_GET['nid'];

		$news = M("article")->where("id = '".$news_id."'")->findall();
		
		$this->assign ("nowp", $_GET['nowp']);		
		$this->assign ("news", $news[0]);
		$this->display("public:news_detail");

	 }
}
?>